﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VIKI.LINQ;
using VIKI.BLL;

namespace VIKI.Web.Home.Login
{
    public partial class Register : System.Web.UI.Page
    {
        private static readonly UserBLL userBll = new UserBLL();
        private string[] userTypes = System.Configuration.ConfigurationManager.AppSettings["UserType"].Split(';');

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.FindControl("TopnavPanel").Visible = false;

            for (int i = 0; i < userTypes.Length; i++)
            {
                UserType.Items.Add(userTypes[i]);
                UserType.Items[i].Value = i.ToString();
            }
        }

        protected void RegisterUser(object sender, EventArgs e)
        {
            User user = new User();
            user.UserId = Guid.NewGuid();
            user.UserEmail = Email.Text.Trim();
            user.UserName = UserName.Text.Trim();
            user.UserPass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text.Trim(), "MD5");
            user.UserType = byte.Parse(UserType.SelectedValue);
            user.UserTel = Tel.Text.Trim();
            Tel.Text = userBll.Insert(user).ToString();
        }
    }
}